  $(function(){
	  //显示权限按钮
	  var parentUUID = $("input[name='parentUUID']").val();
   	  $.permission.showButton(parentUUID,"actionBtnArea");
   	  //表格初始化
	  $.dataGridEasyUI.initTable({
		  pageId:"#memberListPage",
		  gridId:"#memberList",
		  url:getBasePath()+'member/getMemberList.do',
		  toolbarId:"#memberListPage .tb_toolbar",
		  columns:[[
	            {field:'id',checkbox:true},
	            {field:'headImageUrl',title:'头像',width:105,formatter: function(value,row,index){
	            	 var imgPath  = getImgPath()+"/"+value;
	            	 var defaultImgPath = getBasePath()+"manage/images/defaultMan.png";
	            	 if(row.sex!=1){
	            		defaultImgPath = getBasePath()+"manage/images/defaultGirl.png";
	            	 }
	            	 console.log(imgPath);
	            	 var htmlText = "<span><img src='"+imgPath+"' onerror=\"this.src='"+defaultImgPath+"'\" width='100' height='100'/></span>";
		  	    	 return htmlText;
				}},
	            {field:'nickName',title:'登录名',width:'10%'},
	            {field:'realName',title:'姓名',width:'10%'},
	            {field:'mobile',title:'手机号',width:'10%'},
	            {field:'email',title:'邮件',width:'10%'},
	            {field:'sex',title:'性别',width:'10%',formatter: function(value,row,index){
		  	    	if(value=="1"){
		  	    		return "男";
		  	    	}else{
		  	    		return "女";
		  	    	}
				  }
	            },
	            {field:'memberType',title:'用户类型',width:'11%',formatter: function(value,row,index){
	            	if(value=="1"){
	  	    		return "<font color=#0ACF00><b>普通用户</b></font>";
	  	    	}else if(value=="2"){
	  	    		return "<font color=#FF9900><b>企业用户</b></font>";
	  	    	}
				  }},
	            {field:'locked',title:'是否加锁',width:'11%',formatter: function(value,row,index){
	            	if(value=="1"){
	  	    		return "<font color=#E9003A><b>已锁住</b></font>";
	  	    	}else{
	  	    		return "<font color=#0ACF00><b>未锁</b></font>";
	  	    	}
				  }},
	            {field:'createTime',title:'入库时间',width:'11%'}
	        ]]
	  });
  
  //新增按钮绑定事件
  $("#addDataLink").bind("click",function(){
	  $.dataGridEasyUI.initEditWindow({
		  url:getBasePath()+"manage/member/editMember.jsp?showType=window",
		  title:"添加会员信息信息",
		  actionType:"add",
		  width:900,
		  height:455
	  });
  });
  
  //更新按钮绑定事件
  $("#updateDataLink").bind("click",function(){
	  $.dataGridEasyUI.initEditWindow({
		  url:getBasePath()+"manage/member/editMember.jsp?showType=window",
		  title:"编辑会员信息信息",
		  actionType:"update",
		  width:900,
		  height:455
	  });
  });
  
  /**
   * 导入数据
   */
  $("#importDataLink").bind("click",function(){
	  $.dataGridEasyUI.initEditWindow({
		  url:getBasePath()+"manage/member/importMemberXls.jsp?showType=window",
		  title:"导入数据",
		  actionType:"add",
		  width:650,
		  height:300
	  });
  });
  
  
  
  //批量删除
  $("#batchDeleteLink").bind("click",function(){
	  $.dataGridEasyUI.batchDeleteData({
		  url:getBasePath()+"/member/batchDelMemberForHS.do",
	  });
  });
  
  //单个删除
  $("#singleDeleteLink").bind("click",function(){
	  $.dataGridEasyUI.batchDeleteData({
		  url:getBasePath()+"/member/delMember.do",
	  });
  });
  
  //显示详情
  $("#showDetailLink").bind("click",function(){
	  $.dataGridEasyUI.initEditWindow({
		  url:getBasePath() + "manage/member/adminDetail.jsp",
		  title:"展示详情",
		  actionType:"detail",
		  width:650,
		  height:350
	  });
  });


   //图片弹窗
	$(".fancybox-effects-a").fancybox({
		helpers: {
			title : {
				type : 'outside'
			},
			overlay : {
				speedOut : 0
			}
		}
	});
})

//永久删除数据
function batchDelInDB(){
  $.dataGridEasyUI.batchDeleteInDB({
	  url:getBasePath()+"/member/batchDelMember.do",
  });
}
         
         
 //恢复数据
function rebackData(){
	$.dataGridEasyUI.batchDeleteInDB({
		  url:basePath+"/member/batchRebackData.do"
	});
}


//编辑企业信息
function editCompanyData(){
	//验证是否登录--开始
	if(!checkLoginStatus()){return;}
    //验证是否登录--结束
	var editDataFormArea = $("#editDataFormArea");
	if(editDataFormArea.length==0){
		$("<div id='editDataFormArea'></div>").prependTo("body");
	}
	
	var curRow = tableObject.datagrid("getSelected");
	if(curRow!=null){
	    //计算距离
   		var _width = 826;
   		var _height = 444;
   		var x_left = ($(window).width()-_width)/2;
   		var y_top = ($(window).height()-_height)/2;
   		$("#editDataFormArea").window({
   		    title: '编辑会员企业信息',
   		    width: _width,
   		    height: _height,
   		    iconCls:'icon-window',
   		    left:x_left,
   		    top:y_top,
   		    closed: false,
   		    cache: false,
   		    modal: true,
   		    onClose:function(){
       		    $("#editDataFormArea").html("");
       		    $("#editDataFormArea").remove();
   		    },
   		    href:getBasePath()+"manage/member/editCompanyInfo.jsp?memberUUID="+curRow.uuid+"&showType=window"
   		});
	}else{
		$.messager.alert('系统提示',"请先选择要编辑的行",'error');
	}
}